package com.itheima.listener;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;


@Component
public class SpringRabbitListener {
    private static final Logger log = LoggerFactory.getLogger(SpringRabbitListener.class);



    /****
     * topic
     */
    @RabbitListener(queues = "topic.queue1")
    public void listenTopicQueueMessage1(String message) {
        log.info("系统收到消息topic1[" + message + "]");
    }

    @RabbitListener(queues = "topic.queue2")
    public void listenTopicQueueMessage2(String message) {
        log.info("系统收到消息topic2[" + message + "]");
    }


    /****
     * Derect
     * @param message
     */
    @RabbitListener(queues = "direct.queue1")
    public void listenDerectQueueMessage1(String message) {
        log.info("系统收到消息direct1[" + message + "]");
    }

    @RabbitListener(queues = "direct.queue2")
    public void listenDerectQueueMessage2(String message) {
        log.info("系统收到消息direct2[" + message + "]");
    }


    /****
     * 广播模式
     * @param message
     */

    @RabbitListener(queues = "fanout.queue1")
    public void listenFanoutQueueMessage1(String message) {
        log.info("系统收到消息fanoutqueue1[" + message + "]");
    }

    @RabbitListener(queues = "fanout.queue2")
    public void listenFanoutQueueMessage2(String message) {
        log.info("系统收到消息fanoutqueue2[" + message + "]");
    }


    @RabbitListener(queues = "work.queue")
    public void listenSimpleQueueMessage1(String message) {
        log.info("系统收到消息work1[" + message + "]");
    }


    @RabbitListener(queues = "work.queue")
    public void listenSimpleQueueMessage2(String message) {
        log.info("系统收到消息work2[" + message + "]");
    }


}
